// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
// import Vue from 'vue'
import App from './App'
import router from './router'
// import ElementUI from 'element-ui'
//import 'element-ui/lib/theme-chalk/index.css'
import store from './store'
import { getRequest } from './utils/api'
import { addnews } from './utils/api'
import { addkoujue } from './utils/api'


import { delnew } from './utils/api'
import { gongshi } from './utils/api'

import { postRequest } from './utils/api'
import { deleteRequest } from './utils/api'
import { delkoujue } from './utils/api';
import { savegongshi } from './utils/api';
import { putRequest } from './utils/api'
import { postJson, upnews, uploadFileRequest } from './utils/api'
import { initMenu } from './utils/utils'
import { isNotNullORBlank } from './utils/utils'
import { savenews } from './utils/api';
import './utils/filter_utils'
// import echarts from 'echarts'

// import 'font-awesome/css/font-awesome.min.css'

//在main.js加入下面两行代码
// import echarts from 'echarts'
// Vue.prototype.$echarts = echarts //将echarts注册成Vue的全局属性

// require('video.js/dist/video-js.css')
// require('vue-video-player/src/custom-theme.css')
// import VideoPlayer from 'vue-video-player'
// Vue.use(VideoPlayer)

// window.moment = require('moment');
//
// window.moment.locale('zh-cn');



Vue.config.productionTip = false
    // Vue.use(ElementUI)
Vue.prototype.savenews = savenews;
Vue.prototype.addkoujue = addkoujue;
Vue.prototype.delkoujue = delkoujue;
Vue.prototype.savegongshi = savegongshi;
Vue.prototype.delnew = delnew;
Vue.prototype.addnews = addnews;
Vue.prototype.getRequest = getRequest;
Vue.prototype.postRequest = postRequest;
Vue.prototype.gongshi = gongshi;
Vue.prototype.deleteRequest = deleteRequest;
Vue.prototype.putRequest = putRequest;
Vue.prototype.postJson = postJson;
Vue.prototype.isNotNullORBlank = isNotNullORBlank;
Vue.prototype.upnews = upnews;
Vue.prototype.uploadFileRequest = uploadFileRequest;
// Vue.prototype.$echarts = echarts;
//console.log(111)
router.beforeEach((to, from, next) => {
    
    if (to.name == 'Login' || to.name == 'Ding') {
        next();
        return;

    }
    var name = store.state.user.name;
    if (name == '未登录') {
        if (to.meta.requireAuth || to.name == null) {
            next({ path: '/', query: { redirect: to.path } })
        } else {
            next();
        }
    } else {
        initMenu(router, store);
        if (to.path == '/chat')
            store.commit("updateMsgList", []);
        next();

    }
})

new Vue({
    el: '#app',
    router,
    store,
    template: '<App/>',
    components: { App }
})